//
//  NFSPlayBillTableViewCell.m
//  NeedForSpeed
//
//  Created by 王国强 on 15/10/22.
//  Copyright © 2015年 Avenger. All rights reserved.
//

#import "NFSPlayBillTableViewCell.h"

#import "BaseHeader.h"
@implementation NFSPlayBillTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.albumLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH/3,30)];
        [self.albumLabel setTextColor:[UIColor whiteColor]];
        [self.contentView addSubview:self.albumLabel];
        
        self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 30, SCREEN_WIDTH/2, 20)];
        [self.titleLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.titleLabel setTextColor:[UIColor whiteColor]];
        [self.contentView addSubview:self.titleLabel];
        
        self.startOrEndLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH * 2 / 3, 0, SCREEN_WIDTH /3, 20)];
        [self.startOrEndLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.startOrEndLabel setTextColor:[UIColor whiteColor]];
        [self.contentView addSubview:self.startOrEndLabel];
        
        
        self.programtimeLabel = [[UILabel alloc]initWithFrame:CGRectMake(SCREEN_WIDTH / 2, 30, SCREEN_WIDTH / 3, 30)];
        [self.programtimeLabel setFont:[UIFont systemFontOfSize:14.]];
        [self.contentView addSubview:self.programtimeLabel];
        [self.programtimeLabel setTextColor:[UIColor whiteColor]];
    }
    return self;
}
- (void)getModel:(NFSDirectModel *)model
{
    [self.albumLabel setText:model.album];
    [self.programtimeLabel setText:model.programtime];
    [self.titleLabel setText:model.title];
#pragma mark 指定时间输出格式 年 月 日 (24)时 分 秒
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
#pragma mark 获取当前时间
    NSDate *date = [NSDate date];
    NSString *currentStr = [formatter stringFromDate:date];
    
    if ([currentStr compare:model.starttime] >= 0 &&  [currentStr compare:model.endtime] <= 0)  {
        [self.startOrEndLabel setText:@"正在播放"];
        [self.startOrEndLabel setTextColor:[UIColor blueColor]];
    }else if ([currentStr compare:model.endtime ]> 0)
    {
        [self.startOrEndLabel setText:@"已结束"];
        [self.startOrEndLabel setTextColor:[UIColor whiteColor]];
    }else
    {
        [self.startOrEndLabel setText:@"未开始"];
        [self.startOrEndLabel setTextColor: [UIColor whiteColor]];
    }

    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
